<?php

namespace App\Models;

use App\Traits\Relation\CourierRelation;
use Illuminate\Database\Eloquent\SoftDeletes;
use Tymon\JWTAuth\Contracts\JWTSubject;
use Illuminate\Foundation\Auth\User as Authenticatable;

class Courier extends Authenticatable implements JWTSubject
{
    use CourierRelation, SoftDeletes;

    protected $table = 'courier';

    /**
     * 定义不可批量填充字段
     *
     * @var array
     * Date: 2018/05/11
     * @author Tenny
     */
    protected $guarded = ['id'];

    /**
     * 定义隐藏字段
     *
     * @var array
     * Date: 19/03/2018
     * @author George
     */
    protected $hidden = [
        'password', 'updated_at', 'deleted_at'
    ];

    /**
     * 定义密码修改器
     *
     * Date: 2018/1/25
     * @author George
     * @param $value
     */
    public function setPasswordAttribute($value)
    {
        $this->attributes['password'] = bcrypt($value);
    }

    /**
     * 定义用于获取用户信息的主键
     *
     * @return mixed
     */
    public function getJWTIdentifier()
    {
        return $this->getKey();
    }

    /**
     * 自定义Payload内容
     *
     * @return array
     */
    public function getJWTCustomClaims()
    {
        return [

        ];
    }
}
